asm
  ld sp,$FDFF
  end asm
 
#include "./library/smsrnd.bas"
#include "./library/smsdelay.bas"
 
dim eee as uinteger at $E010
dim seed as uinteger at $E012
dim ee0 as uinteger at $E014
dim ee1 as uinteger at $E016
dim ee2 as uinteger at $E018
dim ee3 as uinteger at $E01A
dim eex as uinteger at $E01C
dim eey as uinteger at $E01E

sub chineseheroputchar(txp1 as uinteger,typ1 as uinteger,tch1 as ubyte, tat1 as ubyte):
  poke $D000+((typ1+(txp1*64))bxor %11111000000),tch1
  poke $D800+((typ1+(txp1*64))bxor %11111000000),tat1
  end sub

sub chineseheroputsprite(tla1 as uinteger,txp1 as ubyte, typ1 as ubyte, tid1 as ubyte, tat1 as ubyte, txz1 as ubyte, tyz1 as ubyte):
  poke $FE00+(tla1*8)+0,txp1
  poke $FE00+(tla1*8)+4,typ1
  poke $FE00+(tla1*8)+1,tid1
  poke $FE00+(tla1*8)+6,tat1
  poke $FE00+(tla1*8)+3,txz1
  poke $FE00+(tla1*8)+7,tyz1
  end sub

sub chineseherooffset(txp1 as ubyte,typ1 as ubyte):
  poke $C002,16+txp1 '- offset x
  poke $C000,25+(typ1 bxor $FF) '- offset y
  poke $C001,32
  end sub

seed=0

chineseherooffset(0,0)

for ee1=0 to 63
  for ee0=0 to 31
    seed=smsrnd(seed):ee3=seed
    seed=smsrnd(seed)
    chineseheroputchar(ee0,ee1,seed,ee3 band 32)
    next:next

for ee1=0 to 15
  for ee0=0 to 15
    chineseheroputchar(ee0+11,ee1+19,(ee1*16+ee0),0)
    next:next


eee=0

eex=8:eey=8


do

  chineseheroputchar(0,0, 48+(int(eee/100) mod 10),0)
  chineseheroputchar(1,0, 48+(int(eee/10) mod 10),0)
  chineseheroputchar(2,0, 48+(eee mod 10),0)

  ee1=peek($B802)
  chineseheroputchar(0,1, 48+(int(ee1/100) mod 10),0)
  chineseheroputchar(1,1, 48+(int(ee1/10) mod 10),0)
  chineseheroputchar(2,1, 48+(ee1 mod 10),0)



  ee1=peek($B803)
  chineseheroputchar(0,2, 48+(int(ee1/100) mod 10),0)
  chineseheroputchar(1,2, 48+(int(ee1/10) mod 10),0)
  chineseheroputchar(2,2, 48+(ee1 mod 10),0)

  eex=eex+((ee1 band 2)/2)-((ee1 band 1)/1)
  eey=eey+((ee1 band 8)/8)-((ee1 band 4)/4)


  chineseheroputchar(eex,eey,eee band 127,0)

  eee=eee+1
  loop


do:loop


'---------------------------------------------------------------













for eee=0 to $1FF '- spriteram
  seed=smsrnd(seed)
  poke $FE00+eee,eee
  next

do

for eee=0 to $1FF step 8 '- spriteram

  chineseheroputchar(0,0, 48+(int(eee/100) mod 10),0)
  chineseheroputchar(1,0, 48+(int(eee/10) mod 10),0)
  chineseheroputchar(2,0, 48+(eee mod 10),0)

  seed=smsrnd(seed)
  poke $FE00+eee,seed
  ee0=peek($FE00+eee)
  for ee1=0 to 255
    poke $FE00+eee+0,ee1 '- x
    poke $FE00+eee+1,0   '- id?

    'poke $FE00+eee+2,ee1 '- ?


    poke $FE00+eee+4,ee1 '- y
    poke $FE00+eee+5,0

    'poke $FE00+eee+6,ee1 '- c?

    poke $FE00+eee+3,ee1 '- x zoom?
    poke $FE00+eee+7,ee1 '- y zoom?

    smsdelay(5000)
    next
  poke $FE00+eee,ee0
  next

loop



do:loop

do

for ee1=0 to 63
  for ee0=0 to 31 '- videoram
    seed=smsrnd(seed):ee3=seed
    seed=smsrnd(seed)
    chineseheroputchar(ee0,ee1,seed,ee3)

    chineseheroputchar(0,0, 48+(int(ee1/10) mod 10),0)
    chineseheroputchar(1,0, 48+(ee1 mod 10),0)


    for ee2=0 to $1FF
      poke $FE00+ee2,ee1*4
      next


    smsdelay(10000)
    next:next

for eee=0 to 255
  poke $C000,eee
  smsdelay(1000)
  next

for eee=0 to 255
  poke $C002,eee
  smsdelay(1000)
  next

'for eee=0 to 255
'  poke $C001,eee
'  smsdelay(1000)
'  next




'for eee=$C000 to $CFFF '- spriteram
'  seed=smsrnd(seed)
'  poke eee,seed
'
'  chineseheroputchar(10,10, 48+(int(eee/10000) mod 10),0)
'  chineseheroputchar(11,10, 48+(int(eee/1000) mod 10),0)
'  chineseheroputchar(12,10, 48+(int(eee/100) mod 10),0)
'  chineseheroputchar(13,10, 48+(int(eee/10) mod 10),0)
'  chineseheroputchar(14,10, 48+(eee mod 10),0)
'
'  'smsdelay(100)
'  next

loop

do



for eee=0 to $1FF
  seed=smsrnd(seed)
  poke $FE00+eee,seed

  chineseheroputchar(10,10, 48+(int(eee/100) mod 10),0)
  chineseheroputchar(11,10, 48+(int(eee/10) mod 10),0)
  chineseheroputchar(12,10, 48+(eee mod 10),0)

  smsdelay(10000)
  next



loop


do

for eee=$FE00 to $FFFF '- spriteram
  seed=smsrnd(seed)
  poke eee,seed
  'smsdelay(1000)
  next

loop

do:loop


'- static ADDRESS_MAP_START( chinhero_main_map, AS_PROGRAM, 8, shangkid_state )
'- AM_RANGE(0x0000, 0x9fff) AM_ROM
'- AM_RANGE(0xa000, 0xa000) AM_WRITENOP /* ? */
'- AM_RANGE(0xb000, 0xb000) AM_WRITE(bbx_enable_w)
'- AM_RANGE(0xb001, 0xb001) AM_WRITE(sound_enable_w)
'- AM_RANGE(0xb002, 0xb002) AM_WRITENOP        /* main CPU interrupt-related */
'- AM_RANGE(0xb003, 0xb003) AM_WRITENOP        /* BBX interrupt-related */
'- AM_RANGE(0xb004, 0xb004) AM_WRITE(cpu_reset_w)
'- AM_RANGE(0xb006, 0xb006) AM_WRITENOP        /* coin counter */
'- AM_RANGE(0xb800, 0xb800) AM_READ_PORT("DSW")
'- AM_RANGE(0xb801, 0xb801) AM_READ_PORT("SYSTEM")
'- AM_RANGE(0xb802, 0xb802) AM_READ_PORT("P2")
'- AM_RANGE(0xb803, 0xb803) AM_READ_PORT("P1")
'- AM_RANGE(0xc000, 0xc002) AM_WRITEONLY AM_SHARE("videoreg")
'- AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(videoram_w) AM_SHARE("videoram")
'- AM_RANGE(0xe000, 0xfdff) AM_RAM AM_SHARE("share2")
'- AM_RANGE(0xfe00, 0xffff) AM_RAM AM_SHARE("spriteram")
'- ADDRESS_MAP_END



